home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / TextServices.h < prev    next >
Text File  |  1995-07-06  |  13KB  |  328 lines

  1. /*
  2.      File:        TextServices.h
  3.  
  4.      Contains:    Text Services Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __TEXTSERVICES__
  21. #define __TEXTSERVICES__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __EVENTS__
  30. #include <Events.h>
  31. #endif
  32. /*    #include <Quickdraw.h>                                        */
  33. /*        #include <MixedMode.h>                                    */
  34. /*        #include <QuickdrawText.h>                                */
  35. /*    #include <OSUtils.h>                                        */
  36. /*        #include <Memory.h>                                        */
  37.  
  38. #ifndef __MENUS__
  39. #include <Menus.h>
  40. #endif
  41.  
  42. #ifndef __APPLEEVENTS__
  43. #include <AppleEvents.h>
  44. #endif
  45. /*    #include <Errors.h>                                            */
  46. /*    #include <EPPC.h>                                            */
  47. /*        #include <AppleTalk.h>                                    */
  48. /*        #include <Files.h>                                        */
  49. /*            #include <Finder.h>                                    */
  50. /*        #include <PPCToolbox.h>                                    */
  51. /*        #include <Processes.h>                                    */
  52. /*    #include <Notification.h>                                    */
  53.  
  54. #ifndef __ERRORS__
  55. #include <Errors.h>
  56. #endif
  57.  
  58. #ifndef __COMPONENTS__
  59. #include <Components.h>
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. #if PRAGMA_ALIGN_SUPPORTED
  67. #pragma options align=mac68k
  68. #endif
  69.  
  70. #if PRAGMA_IMPORT_SUPPORTED
  71. #pragma import on
  72. #endif
  73.  
  74.  
  75. enum {
  76.     kTSMVersion                    = 0x200,                        /* Version of the Text Services Manager is 2.0  */
  77.     kTextService                = 'tsvc',                        /* component type for the component description */
  78.     kInputMethodService            = 'inpm',                        /* component subtype for the component description */
  79. /* Component Flags in ComponentDescription */
  80.     bTakeActiveEvent            = 15,                            /* bit set if the component takes active event */
  81.     bHandleAERecording            = 16,                            /* bit set if the component takes care of recording Apple Events <new in vers2.0> */
  82.     bScriptMask                    = 0x00007F00,                    /* bit 8 - 14 */
  83.     bLanguageMask                = 0x000000FF,                    /* bit 0 - 7  */
  84.     bScriptLanguageMask            = bScriptMask + bLanguageMask    /* bit 0 - 14  */
  85. };
  86.  
  87. enum {
  88. /* Hilite styles */
  89.     kCaretPosition                = 1,                            /* specify caret position */
  90.     kRawText                    = 2,                            /* specify range of raw text */
  91.     kSelectedRawText            = 3,                            /* specify range of selected raw text */
  92.     kConvertedText                = 4,                            /* specify range of converted text */
  93.     kSelectedConvertedText        = 5                                /* specify range of selected converted text */
  94. };
  95.  
  96. /* Apple Event constants */
  97. enum {
  98. /* Event class */
  99.     kTextServiceClass            = kTextService,
  100. /* event ID */
  101.     kUpdateActiveInputArea        = 'updt',                        /* update the active Inline area */
  102.     kPos2Offset                    = 'p2st',                        /* converting global coordinates to char position */
  103.     kOffset2Pos                    = 'st2p',                        /* converting char position to global coordinates */
  104.     kShowHideInputWindow        = 'shiw',                        /* show or hide the input window */
  105. /* Event keywords */
  106.     keyAETSMDocumentRefcon        = 'refc',                        /* TSM document refcon, typeLongInteger */
  107. /* Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize
  108.     typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to 
  109.     AERegistry.h */
  110.     keyAEServerInstance            = 'srvi',                        /* component instance */
  111.     keyAETheData                = 'kdat',                        /* typeText */
  112.     keyAEFixLength                = 'fixl',                        /* fix len ?? */
  113.     keyAEHiliteRange            = 'hrng',                        /* hilite range array */
  114.     keyAEUpdateRange            = 'udng',                        /* update range array */
  115.     keyAEClauseOffsets            = 'clau',                        /* Clause Offsets array */
  116.     keyAECurrentPoint            = 'cpos',                        /* current point */
  117.     keyAEDragging                = 'bool',                        /* dragging falg */
  118.     keyAEOffset                    = 'ofst',                        /* offset */
  119.     keyAERegionClass            = 'rgnc',                        /* region class */
  120.     keyAEPoint                    = 'gpos',                        /* current point */
  121.     keyAEBufferSize                = 'buff',                        /* buffer size to get the text */
  122.     keyAEMoveView                = 'mvvw',                        /* move view flag */
  123.     keyAELength                    = 'leng',                        /* length */
  124.     keyAENextBody                = 'nxbd',                        /* next or previous body */
  125. /* optional keywords for Offset2Pos (Info about the active input area) */
  126.     keyAETextLineHeight            = 'ktlh',                        /* typeShortInteger */
  127.     keyAETextLineAscent            = 'ktas',                        /* typeShortInteger */
  128. /* optional keywords for Pos2Offset */
  129.     keyAELeftSide                = 'klef',                        /* type Boolean */
  130. /* optional keywords for kShowHideInputWindow */
  131.     keyAEShowHideInputWindow    = 'shiw',                        /* type Boolean */
  132. /* for PinRange  */
  133.     keyAEPinRange                = 'pnrg',
  134. /* Desc type ... */
  135.     typeComponentInstance        = 'cmpi',                        /* server instance */
  136.     typeTextRangeArray            = 'tray',                        /* text range array */
  137.     typeOffsetArray                = 'ofay',                        /* offset array */
  138.     typeText                    = typeChar,                        /* Plain text */
  139.     typeTextRange                = 'txrn'
  140. };
  141.  
  142. /* Desc type constants */
  143. enum {
  144.     kTSMOutsideOfBody            = 1,
  145.     kTSMInsideOfBody            = 2,
  146.     kTSMInsideOfActiveInputArea    = 3
  147. };
  148.  
  149. enum {
  150.     kNextBody                    = 1,
  151.     kPreviousBody                = 2
  152. };
  153.  
  154. enum {
  155. /* Low level routines which are dispatched directly to the Component Manager */
  156.     kCMGetScriptLangSupport        = 0x0001,                        /* Component Manager call selector 1 */
  157.     kCMInitiateTextService        = 0x0002,                        /* Component Manager call selector 2 */
  158.     kCMTerminateTextService        = 0x0003,                        /* Component Manager call selector 3 */
  159.     kCMActivateTextService        = 0x0004,                        /* Component Manager call selector 4 */
  160.     kCMDeactivateTextService    = 0x0005,                        /* Component Manager call selector 5 */
  161.     kCMTextServiceEvent            = 0x0006,                        /* Component Manager call selector 6 */
  162.     kCMGetTextServiceMenu        = 0x0007,                        /* Component Manager call selector 7 */
  163.     kCMTextServiceMenuSelect    = 0x0008,                        /* Component Manager call selector 8 */
  164.     kCMFixTextService            = 0x0009,                        /* Component Manager call selector 9 */
  165.     kCMSetTextServiceCursor        = 0x000A,                        /* Component Manager call selector 10 */
  166.     kCMHidePaletteWindows        = 0x000B                        /* Component Manager call selector 11 */
  167. };
  168.  
  169. /* typeTextRange         'txrn' */
  170. struct TextRange {
  171.     long                            fStart;
  172.     long                            fEnd;
  173.     short                            fHiliteStyle;
  174. };
  175. typedef struct TextRange TextRange;
  176.  
  177. typedef TextRange *TextRangePtr;
  178.  
  179. typedef TextRangePtr *TextRangeHandle;
  180.  
  181. /* typeTextRangeArray    'txra' */
  182. struct TextRangeArray {
  183.     short                            fNumOfRanges;                /* specify the size of the fRange array */
  184.     TextRange                        fRange[1];                    /* when fNumOfRanges > 1, the size of this array has to be calculated */
  185. };
  186. typedef struct TextRangeArray TextRangeArray;
  187.  
  188. typedef TextRangeArray *TextRangeArrayPtr;
  189.  
  190. typedef TextRangeArrayPtr *TextRangeArrayHandle;
  191.  
  192. /* typeOffsetArray        'offa' */
  193. struct OffsetArray {
  194.     short                            fNumOfOffsets;                /* specify the size of the fOffset array */
  195.     long                            fOffset[1];                    /* when fNumOfOffsets > 1, the size of this array has to be calculated */
  196. };
  197. typedef struct OffsetArray OffsetArray;
  198.  
  199. typedef OffsetArray *OffsetArrayPtr;
  200.  
  201. typedef OffsetArrayPtr *OffsetArrayHandle;
  202.  
  203. #define mGetScriptCode(cdRec) ((ScriptCode)    ((cdRec.componentFlags & bScriptMask) >> 8))
  204. #define mGetLanguageCode(cdRec) ((LangCode)    cdRec.componentFlags & bLanguageMask)
  205. typedef void *TSMDocumentID;
  206.  
  207. typedef OSType InterfaceTypeList[1];
  208.  
  209. /* Text Service Info List */
  210. struct TextServiceInfo {
  211.     Component                        fComponent;
  212.     Str255                            fItemName;
  213. };
  214. typedef struct TextServiceInfo TextServiceInfo;
  215.  
  216. typedef TextServiceInfo *TextServiceInfoPtr;
  217.  
  218. struct TextServiceList {
  219.     short                            fTextServiceCount;            /* number of entries in the 'fServices' array */
  220.     TextServiceInfo                    fServices[1];                /* Note: array of 'TextServiceInfo' records follows */
  221. };
  222. typedef struct TextServiceList TextServiceList;
  223.  
  224. typedef TextServiceList *TextServiceListPtr;
  225.  
  226. typedef TextServiceListPtr *TextServiceListHandle;
  227.  
  228. struct ScriptLanguageRecord {
  229.     ScriptCode                        fScript;
  230.     LangCode                        fLanguage;
  231. };
  232. typedef struct ScriptLanguageRecord ScriptLanguageRecord;
  233.  
  234. struct ScriptLanguageSupport {
  235.     short                            fScriptLanguageCount;        /* number of entries in the 'fScriptLanguageArray' array */
  236.     ScriptLanguageRecord            fScriptLanguageArray[1];    /* Note: array of 'ScriptLanguageRecord' records follows */
  237. };
  238. typedef struct ScriptLanguageSupport ScriptLanguageSupport;
  239.  
  240. typedef ScriptLanguageSupport *ScriptLanguageSupportPtr;
  241.  
  242. typedef ScriptLanguageSupportPtr *ScriptLanguageSupportHandle;
  243.  
  244. extern pascal OSErr NewTSMDocument(short numOfInterface, InterfaceTypeList supportedInterfaceTypes, TSMDocumentID *idocID, long refcon)
  245.  TWOWORDINLINE(0x7000, 0xAA54);
  246. extern pascal OSErr DeleteTSMDocument(TSMDocumentID idocID)
  247.  TWOWORDINLINE(0x7001, 0xAA54);
  248. extern pascal OSErr ActivateTSMDocument(TSMDocumentID idocID)
  249.  TWOWORDINLINE(0x7002, 0xAA54);
  250. extern pascal OSErr DeactivateTSMDocument(TSMDocumentID idocID)
  251.  TWOWORDINLINE(0x7003, 0xAA54);
  252. extern pascal Boolean TSMEvent(EventRecord *event)
  253.  TWOWORDINLINE(0x7004, 0xAA54);
  254. extern pascal Boolean TSMMenuSelect(long menuResult)
  255.  TWOWORDINLINE(0x7005, 0xAA54);
  256. extern pascal Boolean SetTSMCursor(Point mousePos)
  257.  TWOWORDINLINE(0x7006, 0xAA54);
  258. extern pascal OSErr FixTSMDocument(TSMDocumentID idocID)
  259.  TWOWORDINLINE(0x7007, 0xAA54);
  260. extern pascal OSErr GetServiceList(short numOfInterface, OSType *supportedInterfaceTypes, TextServiceListHandle *serviceInfo, long *seedValue)
  261.  TWOWORDINLINE(0x7008, 0xAA54);
  262. extern pascal OSErr OpenTextService(TSMDocumentID idocID, Component aComponent, ComponentInstance *aComponentInstance)
  263.  TWOWORDINLINE(0x7009, 0xAA54);
  264. extern pascal OSErr CloseTextService(TSMDocumentID idocID, ComponentInstance aComponentInstance)
  265.  TWOWORDINLINE(0x700A, 0xAA54);
  266. extern pascal OSErr SendAEFromTSMComponent(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc)
  267.  TWOWORDINLINE(0x700B, 0xAA54);
  268. extern pascal OSErr InitTSMAwareApplication(void)
  269.  TWOWORDINLINE(0x7014, 0xAA54);
  270. extern pascal OSErr CloseTSMAwareApplication(void)
  271.  TWOWORDINLINE(0x7015, 0xAA54);
  272. /* Utilities */
  273. extern pascal OSErr SetDefaultInputMethod(Component ts, ScriptLanguageRecord *slRecordPtr)
  274.  TWOWORDINLINE(0x700C, 0xAA54);
  275. extern pascal OSErr GetDefaultInputMethod(Component *ts, ScriptLanguageRecord *slRecordPtr)
  276.  TWOWORDINLINE(0x700D, 0xAA54);
  277. extern pascal OSErr SetTextServiceLanguage(ScriptLanguageRecord *slRecordPtr)
  278.  TWOWORDINLINE(0x700E, 0xAA54);
  279. extern pascal OSErr GetTextServiceLanguage(ScriptLanguageRecord *slRecordPtr)
  280.  TWOWORDINLINE(0x700F, 0xAA54);
  281. extern pascal OSErr UseInputWindow(TSMDocumentID idocID, Boolean useWindow)
  282.  TWOWORDINLINE(0x7010, 0xAA54);
  283. extern pascal OSErr NewServiceWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, ComponentInstance ts, WindowPtr *window)
  284.  TWOWORDINLINE(0x7011, 0xAA54);
  285. extern pascal OSErr CloseServiceWindow(WindowPtr window)
  286.  TWOWORDINLINE(0x7012, 0xAA54);
  287. extern pascal OSErr GetFrontServiceWindow(WindowPtr *window)
  288.  TWOWORDINLINE(0x7013, 0xAA54);
  289. extern pascal short FindServiceWindow(Point thePoint, WindowPtr *theWindow)
  290.  TWOWORDINLINE(0x7017, 0xAA54);
  291. /* Low level TSM routines */
  292. extern pascal ComponentResult GetScriptLanguageSupport(ComponentInstance ts, ScriptLanguageSupportHandle *scriptHdl)
  293.  FIVEWORDINLINE(0x2F3C, 0x04, 0x0001, 0x7000, 0xA82A);
  294. extern pascal ComponentResult InitiateTextService(ComponentInstance ts)
  295.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0002, 0x7000, 0xA82A);
  296. extern pascal ComponentResult TerminateTextService(ComponentInstance ts)
  297.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0003, 0x7000, 0xA82A);
  298. extern pascal ComponentResult ActivateTextService(ComponentInstance ts)
  299.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0004, 0x7000, 0xA82A);
  300. extern pascal ComponentResult DeactivateTextService(ComponentInstance ts)
  301.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0005, 0x7000, 0xA82A);
  302. extern pascal ComponentResult TextServiceEvent(ComponentInstance ts, short numOfEvents, EventRecord *event)
  303.  FIVEWORDINLINE(0x2F3C, 0x06, 0x0006, 0x7000, 0xA82A);
  304. extern pascal ComponentResult GetTextServiceMenu(ComponentInstance ts, MenuHandle *serviceMenu)
  305.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0007, 0x7000, 0xA82A);
  306. extern pascal ComponentResult TextServiceMenuSelect(ComponentInstance ts, MenuHandle serviceMenu, short item)
  307.  FIVEWORDINLINE(0x2F3C, 0x06, 0x0008, 0x7000, 0xA82A);
  308. extern pascal ComponentResult FixTextService(ComponentInstance ts)
  309.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0009, 0x7000, 0xA82A);
  310. extern pascal ComponentResult SetTextServiceCursor(ComponentInstance ts, Point mousePos)
  311.  FIVEWORDINLINE(0x2F3C, 0x04, 0x000A, 0x7000, 0xA82A);
  312. extern pascal ComponentResult HidePaletteWindows(ComponentInstance ts)
  313.  FIVEWORDINLINE(0x2F3C, 0x00, 0x000B, 0x7000, 0xA82A);
  314.  
  315. #if PRAGMA_IMPORT_SUPPORTED
  316. #pragma import off
  317. #endif
  318.  
  319. #if PRAGMA_ALIGN_SUPPORTED
  320. #pragma options align=reset
  321. #endif
  322.  
  323. #ifdef __cplusplus
  324. }
  325. #endif
  326.  
  327. #endif /* __TEXTSERVICES__ */
  328.